using System;
using System.Text;
using System.IO;

namespace LibraryImport
{
    public static partial class Artists
    {
        /// <summary>
        /// Returns an ID3 tag "Artist"
        /// </summary>
        /// <param name="FileFullPath">Path to file</param>
        /// <returns></returns>
        private static String GetID3ArtistTag(String FileName)
        {
            FileStream file = new FileStream(FileName, FileMode.Open, FileAccess.Read);

            Byte[] TAGtag = new Byte[3];
            file.Seek(-128, SeekOrigin.End);
            file.Read(TAGtag, 0, 3);

            if (Encoding.ASCII.GetString(TAGtag) == "TAG")
            {
                Byte[] TAGArtist = new Byte[30];
                file.Seek(30, SeekOrigin.Current);
                file.Read(TAGArtist, 0, 30);
                file.Close();
                Array.Resize<Byte>(ref TAGArtist, Array.IndexOf<Byte>(TAGArtist, 0));
                return Encoding.Default.GetString(TAGArtist);
            }

            throw new Exception();
        }
    }
}